package rs.fon.is.music.domain;

import java.util.Collection;
import java.util.LinkedList;

import rs.fon.is.music.util.Constants;
import thewebsemantic.Namespace;
import thewebsemantic.RdfProperty;
import thewebsemantic.RdfType;

@Namespace(Constants.SCHEMA)
@RdfType("MusicAlbum")
public class MusicAlbum extends Thing {
	
	@RdfProperty(Constants.SCHEMA + "numTracks")
	private int numTracks;
	
	@RdfProperty(Constants.SCHEMA + "interactionCount")
	private String interactionCount;
	
	@RdfProperty(Constants.SCHEMA + "keywords")
	private Collection<String> keywords;
	
	@RdfProperty(Constants.SCHEMA + "byArtist")
	private MusicGroup artist;
	
	@RdfProperty(Constants.SCHEMA + "tracks")
	private Collection<MusicRecording> tracks;

	public MusicAlbum() {
		this.tracks = new LinkedList<>();
		this.keywords = new LinkedList<>();
	}
	
	public int getNumTracks() {
		return numTracks;
	}

	public void setNumTracks(int numTracks) {
		this.numTracks = numTracks;
	}

	public Collection<MusicRecording> getTracks() {
		return tracks;
	}

	public void setTracks(Collection<MusicRecording> tracks) {
		this.tracks = tracks;
	}
	
	
	public String getInteractionCount() {
		return interactionCount;
	}

	public void setInteractionCount(String interactionCount) {
		this.interactionCount = interactionCount;
	}

	public Collection<String> getKeywords() {
		return keywords;
	}

	public void setKeywords(Collection<String> keywords) {
		this.keywords = keywords;
	}
	
	public void addKeyword(String keyword){
		this.keywords.add(keyword);
	}

	public MusicGroup getArtist() {
		return artist;
	}

	public void setArtist(MusicGroup artist) {
		this.artist = artist;
	}

	public void addTrack(MusicRecording mr) {
		this.tracks.add(mr);
	}

	@Override
	public String toString() {
		
		String keywordsString = "";
		for (String keyword : keywords) {
			keywordsString += " " + keyword + ",";
		}
		if(!keywordsString.isEmpty())
			keywordsString = keywordsString.substring(0, keywordsString.length()-1);
		
		String s = "Music album: " + getName()
				+ "\nURI: " + getUri() 
				+ "\nURL: " + getUrl() 
				+ "\nimage: " + getImage() 
				+ "\nnumTracks: " + getNumTracks()
				+ "\ninteractionCount: " + getInteractionCount()
				+ "\nkeywords:" + keywordsString
				+ "\nbyArtist: " + getArtist().getName();
		
		/*if(getTracks().size()>0){
			for (MusicRecording r : getTracks()) {
				s += "\n\n" + r.toString();
			}
		}*/
		
		return s;
	}
	
}
